Skip to content

Conversation

@AlexisMora
Copy link
Contributor

@AlexisMora AlexisMora commented Dec 29, 2025

What is Changed / Added

AuthService.getAuthDetails now properly handles the case where the backend detects an old token version during the call to refreshUserToken. When this specific error occurs, the system automatically clears the stored user credentials and throws a dedicated OldTokenDetectedError. This change aims to prevents users from getting stuck in a broken authentication state where their local token is no longer valid on the server.

In the following trace you can see the error I am trying to fix with this pull request

{
  "level": "error",
  "message": "[REPORTED_ERROR]: Old token version detected\nProperties => {\n  \"command\": \"webdav\"\n}\nStack => Error: Old token version detected\n    at new AppError (/usr/lib/node_modules/@internxt/cli/node_modules/@internxt/sdk/dist/shared/types/errors.js:21:28)\n    at HttpClient.normalizeError (/usr/lib/node_modules/@internxt/cli/node_modules/@internxt/sdk/dist/shared/http/client.js:190:15)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async Axios.request (/usr/lib/node_modules/@internxt/cli/node_modules/axios/dist/node/axios.cjs:4478:14)\n    at async AuthService.refreshUserToken (/usr/lib/node_modules/@internxt/cli/dist/services/auth.service.js:79:26)\n    at async AuthService.getAuthDetails (/usr/lib/node_modules/@internxt/cli/dist/services/auth.service.js:54:26)\n    at async Webdav.run"
}

The method in charge of validating and checking the expiration of the token validateTokenAndCheckExpiration was refactored to separate concerns more clearly. This way it is easier to test and reason about token states throughout the authentication flow.

Two new error detection utilities isFileNotFoundError and isOldTokenError were added to identify file system errors and old token errors more reliably.

ConfigService.clearUser was also updated to gracefully handle cases where the credentials file doesn't exist during cleanup operations.

@sonarqubecloud
Copy link

@AlexisMora AlexisMora marked this pull request as ready for review December 29, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants